import {IBaseInfo} from "@/@types/main"
import {loginByCredentialsSimulate} from "@/utils"
const solve = (loginInfo: IBaseInfo) => {
  const userLoginInfo = JSON.parse(loginInfo.token)
  const info = {
    site: userLoginInfo.site,
    pwd: {
      name: userLoginInfo.name,
      pwd: userLoginInfo.pwd
    }
  }
  const className = {
    username: ".n-form > div:nth-child(1) input",
    password: ".n-form > div:nth-child(2) input",
    loginBtn: ".n-form > div:nth-child(3) button"
  }
  loginByCredentialsSimulate(info, className)
  
  // const info = JSON.parse(loginInfo.token);
  // const AUTH_TOKEN = {
  //   token: info.token,
  //   userInfo: {
  //     ...info,
  //     token: ""
  //   }
  // }
  // console.log(`JSON.stringify(AUTH_TOKEN)`, JSON.stringify(AUTH_TOKEN));
  
  // localStorage.setItem("AUTH_TOKEN", JSON.stringify(AUTH_TOKEN));
  // console.log(`loginInfo.domain`, loginInfo.domain);
  
  // location.href = loginInfo.domain;
}

export default {
  solve
}
